<?php

namespace App\Listeners;


use App\Events\InfoChecked;
use App\Models\Info;

class InfoEventSubscriber
{
    public function onInfoChecked(InfoChecked $event){
        $info = $event->info;
        if (!$info->status){
            $info->status = Info::INFO_STATUS_WATCHED;
            $info->save();
        }

    }

    /**
     * 注册监听器
     *
     * @param  \Illuminate\Events\Dispatcher  $events
     */
    public function subscribe($event){

        $event->listen(
            'App\Events\InfoChecked',
            'App\Listeners\InfoEventSubscriber@onInfoChecked'
        );
    }
}
